package org.xiangxji.snippets.db;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnectUtils {
	
	public static Connection getConnection(String url, String username, String password) throws IOException {
		Connection conn = null;
		
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url, username,password);
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			throw new IOException("数据库连接失败", e);
		}
		
		return conn;
	}


}
